<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head_latest.inc"%>
    <title>Edit</title>
    <style type="text/css">
    	html,body{
			background: #fff;
    	}
    </style>
</head>
<body style="padding:0px;">
  
  <form id="mainform" method="post">
  	 <input type="hidden" name="pid" value="${pid}"/>
  	 <input type="hidden" name="csId" value="${csId}"/>
  	 <div class="l-group">
		<span>基本信息</span>
	 </div>
  </form> 
      
  <script type="text/javascript">
  		var pkId = '${id}';
  		//tab
  		var tab = $("#tabcontainer").ligerTab();
         
        function badousoft(){}
			badousoft.ajax=function(s){
			    jQuery.ajax(s);
		}	

  	  var baseUrl = '${baseURL}/report/metadataexpression/metadataexpression';
  	 
      //button 
      //edit add
	  var mainform = $("#mainform");
      mainform.ligerForm({ 
          fields: [
		        { name: "id", type: "hidden" },
		        { display: "名称", name: "name", newline: true, labelWidth: 100, width: 320, space: 30, type: "text" ,
		       	 validate: { required: true, maxlength: 50}
		        },
		        { display: "值", name: "value", newline: true, labelWidth: 100, width: 320, space: 30, type: "text" ,
		       	 validate: {maxlength: 50}
		        },
		        { display: "值表达式", name: "valueExpression", newline: true, labelWidth: 100, width: 320, space: 30, type: "text" ,
		       	 validate: { required: false, maxlength: 50}
		        },
		        { display: "是否隐藏列", name: "hideDesc", newline: true, labelWidth: 100, width: 320, space: 30, type: "select" ,
		       	 options:{data:[{ id: 0, text: '显示' },{ id: 1, text: '隐藏' }],valueFieldID:"hide"},validate: { required: false, maxlength: 50}
		        },
		        { display: "类型", name: "typeDesc", newline: true, labelWidth: 100, width: 320, space: 30, type: "select" ,
		       	 validate: { required: false, maxlength: 50},options:{data:[{ id: 'text', text: '文本类型' },{ id: 'date', text: '日期类型' }],valueFieldID:"type"}
		        }
 		 ],
          toJSON: JSON2.stringify
      });
        
      $("[name=value]").attr("placeholder","fieldName");
      $("[name=valueExpression]").attr("placeholder","匹配{fieldName},如{num1}/{num2}*100%");
     
      //validate
     jQuery.metadata.setType("attr", "validate"); 
     LG.validate(mainform);
     
     $('<input type="button" value="保存" onclick="javascript:FF_Save();"  style="margin-left:110px;margin-top:30px;" class="l-button l-button-submit" />').appendTo(mainform);
     $('<input type="reset" value="取消" onclick="javascript:FF_Cancel();" style="margin-left:30px;margin-top:30px;" class="l-button l-button-test" />').appendTo(mainform);
  	
	
     //save
     function FF_Save(){
     	 		 mainform.attr("action",baseUrl+"save/save.do?id=${id}");
           	 	 LG.submitForm(mainform, function (data) {
           		  var win = parent || window;
                  if (data && data.hasOk) {  
                        alert('保存成功!');
                        parent.parent.document.getElementById("titlesParamsTabFrame").src = parent.parent.document.getElementById("titlesParamsTabFrame").src.split("&currentNodeId")[0]+"&currentNodeId="+data.bean.id
                        parent.parent.tab.reload('titlesParamsTab'); 
                   } else { 
  					 alert("操作失败，原因如下:\n"+data.message+"\n请联系系统管理员!");
                   }
                 });	
     }
     //Cancel
    function FF_Cancel(){
    	var win = parent || window;
        win.LG.closeCurrentTab("MetadataExpressionEdit");
    }
     //After Loaded
     function FF_AfterLoaded(){
    	 //do noting
     }

  </script>
  <script type="text/javascript">
      //load data
      LG.loadForm({mainForm: mainform, 
    	  url:baseUrl+'edit/editJSON.do?id=${id}',callback: FF_AfterLoaded});
        
  </script>
</body>
</html